package com.xique.community.biz.service.impl;

import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.xique.common.core.web.domain.AjaxResult;
import com.xique.community.bean.domain.User;
import com.xique.community.biz.service.IUserBizService;
import com.xique.community.service.IUserService;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @author shd
 * @create 2021/9/24 11:13
 */
@Service
public class UserBizServiceImpl implements IUserBizService {

    private IUserService userService;

    @Override
    public AjaxResult getUserInfo(Long userId) {

        User user = userService.selectUserById(userId);

        if (null == user) {
            return AjaxResult.error("失败，未找到对应用户");
        }

        return AjaxResult.success("成功", user);
    }

    @Override
    public AjaxResult getUserList(List<Long> userIds) {

        List<User> list = userService.selectUserByIds(userIds);

        if (CollectionUtils.isEmpty(list)) {
            return AjaxResult.error("失败，未找到对应用户");
        }

        return AjaxResult.success("成功", Collections.singletonMap("list", list));
    }
}
